# -*- coding: utf-8 -*-
"""
@Time    : 2020/5/18 14:22
@Author  : Corey
"""
from PyQt5.QtCore import QThread, pyqtSignal
from collections import OrderedDict


class WriteImgThread(QThread):
    Data = pyqtSignal(OrderedDict, str)

    def __init__(self, label_list, data_list, path):
        super().__init__()
        self.label_list = label_list[1:-2]
        self.data_list = data_list  # data_list [[], []]
        self.filepath = path.replace(".csv", ".png")

    def run(self):
        result_dict = OrderedDict()
        for label in self.label_list:
            result_dict[label] = []
        for row_list in self.data_list:
            index = 0
            row_list = row_list[1:-2]
            for label in self.label_list:
                result_dict[label].append(row_list[index])
                index += 1
        self.Data.emit(result_dict, self.filepath)

